/*
 * TripleBuffer.h
 *
 *  Created on: Apr 2, 2012
 *      Author: s90085
 */

#ifndef TRIPLEBUFFER_H_
#define TRIPLEBUFFER_H_

#include "conc/Monitor.h"
#include "Buffer.h"
#include "CameraBuffer.h"
#include "conc/xprintf.h"
#include <iostream>

class TripleBuffer: private Monitor {

private:
	Buffer* readp;	// P rol: wordt gelezen
	Buffer* prevp;	// Q rol: net gevuld/reserve
	Buffer* fillp;	// R rol: wordt gevuld

	bool canRead;
	bool firstFill;

public:
	TripleBuffer( Buffer*, Buffer*, Buffer* );
	~TripleBuffer();
	Buffer* getReadBuffer();
	Buffer* getFillBuffer();
	void swapBuffer(Buffer* &, Buffer* &);
	void replaceBuffer(int, Buffer* &);
	void clearBuffer(Buffer*&);
	Buffer* getFirstFillBuffer();
};

#endif /* TRIPLEBUFFER_H_ */
